package com.movie.admin.controller;

import com.movie.admin.entity.ComingSoon;
import com.movie.admin.service.ComingSoonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/coming-soon")
@CrossOrigin
public class ComingSoonController {
    @Autowired
    private ComingSoonService comingSoonService;

    @GetMapping
    public List<ComingSoon> list() {
        return comingSoonService.list();
    }

    @PostMapping
    public ComingSoon add(@RequestBody ComingSoon comingSoon) {
        comingSoonService.save(comingSoon);
        return comingSoon;
    }

    @PutMapping("/{id}")
    public ComingSoon update(@PathVariable Integer id, @RequestBody ComingSoon comingSoon) {
        comingSoon.setId(id);
        comingSoonService.updateById(comingSoon);
        return comingSoon;
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Integer id) {
        comingSoonService.removeById(id);
    }

    @GetMapping("/{id}")
    public ComingSoon getById(@PathVariable Integer id) {
        return comingSoonService.getById(id);
    }
} 